package appconfig

import (
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type Viper struct {
	MysqlConfig struct {
		User string
		Pass string
		Host string
		Port int
		Data string
	}
	RedisConfig struct {
		Addr string
		Pass string
		DB   int
	}
}

var Conf Viper

func Init() {
	viper.SetConfigFile("./appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("读取文件配置失败")
	} else {
		logx.Info("读取文件配置成功")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		panic("解析文件配置失败")
	} else {
		logx.Info("解析文件配置成功")
	}
}
